package edu.chinasoft.aop02;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component(value = "movie")
public
class Movie {
    //表示电影的状态state    0不好    1 好   2影院的环境差
    private int state;
    private Log log = LogFactory.getLog( Movie.class );
    public void run() throws Exception{
        log.info( "电影开始播放……" );
        if (state==0){
            throw new PoorQualityException("电影质量太差，要求退票！");
        }else if (state==1){
            log.info( "电影在播放中……" );
        }else if(state==2){
            throw new PoorEnvironmentException("有小孩哭闹，环境太差！");
        }else {
            throw new Exception( "发生特殊情况！" );
        }
        log.info( "电影结束播放……" );
    }

    public
    int getState() {
        return state;
    }
    @Value( value = "0")
    public
    void setState(int state) {
        this.state = state;
    }
}
